<?php
require_once("../../../config.inc.php");
require_once("../../../app/_inc/include.php");

$objUser = $_SESSION[USEROBJ];
$numElem = 0;
$errMsg = sxREQ('msg');
$module = sxREQ('mod');
$functionalArea = sxREQ('fa');

if($module==''){
	$url = $_SESSION[USEROBJ]->getHistory(-1, true).
		"&msg=".urlencode(_t("variabile 'mod' non passata")); 
	serverRedir($url);
}
if($functionalArea==''){
	$url = $_SESSION[USEROBJ]->getHistory(-1, true).
		"&msg=".urlencode(_t("variabile 'fa' non passata")); 
	serverRedir($url);
}

//carico l'elenco dei moduli'
$sSQL = "SELECT sm.*, m.description AS descr_module, fa.description AS descr_fa
		FROM module m 
		INNER JOIN functional_area fa ON fa.module=m.module 
			AND fa.functional_area = '$functionalArea'
		LEFT JOIN sub_module sm ON m.module=sm.module 
			AND sm.functional_area = '$functionalArea'
		WHERE m.module='$module' ORDER BY sm.sub_module";
$objSDAO->query($sSQL, "mod");
if (!$row = $objSDAO->fetch("mod")) {
	$url = $_SESSION[USEROBJ]->getHistory(-1, true).
		"&msg=".urlencode(_t("area funzionale '%s' inesistente",$module.'.'.$functionalArea)); 
	serverRedir($url);
}
//output HTML
$aOpz = array("tit2"=>_t("Lista dei sotto-moduli"));
echo(headerHTML($aOpz));
echo(bodyHTML($aOpz));
//output comandi
$aCmd = array("ins"=>array("pag"=>"subModIns.php?mod=$module&fa=$functionalArea",
										"title"=>_t("Inserisce un nuovo sotto-modulo"),
										"text"=>_t("nuovo sotto-modulo"),
										"perm"=>"newmod"),
					"back"=>array("pag"=>$objUser->getHistory(-1,false),
										"title"=>$objUser->getHistoryText(-1),
										"text"=>$objUser->getHistoryText(-1),
										"perm"=>"")
					);
echo(commandsHTML($aCmd));	
//output dei dati
echo("<table class='tabl01' width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
echo("<tr>" .
		"<td class=\"titl01\"colspan=\"3\">" .
		"<table class='tabl01' width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">\n" .
		"<tr><td class=\"titl01\" width='15%'>"._t("Modulo").
		":</td><td class=\"titl01\"><a class=\"titl01\" href=\"moduleView.php?mod=$module&xsn=".XSN.
		"\">$module</a> - ".sxHE($row["descr_module"]).
		"</td></tr>\n<tr><td class=\"titl01\">Area funzionale:</td><td class=\"titl01\">$functionalArea - ".
		sxHE($row["descr_fa"])."</td></tr></table></td>" .
	"</tr>\n");
echo("<tr>" .
		"<td class=\"tabh01\" width=\"1%\">&nbsp;</td>" .		
		"<td class=\"tabh01\" width=\"15%\">"._t('Sotto modulo')."</td>" .
		"<td class=\"tabh01\" width=\"84%\">"._t('Descrizione')."</td>" .
	"</tr>\n");	
while($row){
		if($row['sub_module']!=''){
			$numElem ++;
			echo("<tr>" .
					"<td class=\"text01\" valign='top'><a class=\"text01\" ".
						goToPag("../unit/puList.php?mod=".$row["module"]."&sub=".$row["sub_module"]."&xsn=".XSN).
						" title=\""._t("Lista processi")." '".sxHE($row["description"])."'\">".
						"<img src='".SERVER_URL_ROOT."/app/_img/s_process.png' border='0'></a></td>\n" .
					"<td class=\"text01\" valign='top'><a class=\"text01\" ".
						goToPag("subModView.php?mod=".$row["module"]."&sub=".$row["sub_module"]."&xsn=".XSN).
						" title=\""._t("visualizza ")."'".sxHE($row["description"])."'\">".
						$row["sub_module"]."</a></td>\n" .
					"<td class=\"text01\" valign='top'>".sxHE($row["description"])."</td>" .
				"</tr>\n");
		}
		$row = $objSDAO->fetch("mod");
	}
if($numElem == 0)
	echo("<tr>" .
			"<td class=\"text01\" colspan=\"3\">"._t("Non &egrave; presente alcun sotto-modulo.")."</td>".
		"</tr>\n");
echo("</table>\n");
echo("<div id=\"mess01\" class=\"mess01\">$errMsg</div>");
echo(commandsHTML($aCmd));
echo(footerHTML());
?>
		
?>
